# This is the comet part of the djando server. It will receive many request from the client and answer them if they need to send update requests

from django.http import HttpResponse
from django.utils import simplejson

from market.models import MarketPlacePlayerMarketUpToDateStatus
from market.models import ChatRoomPlayerUpToDateStatus

from market.models import Player


###########################################################################################
# return the market player status creating one if necessary
def getMarketPlacePlayerStatus( dbPlayer ):
        playerSatus = MarketPlacePlayerMarketUpToDateStatus.objects.filter( player = dbPlayer )
        if len( playerSatus )!= 0:
                return playerSatus[0]
        ps = MarketPlacePlayerMarketUpToDateStatus( player = dbPlayer )
        ps.save()
        return ps


###########################################################################################
# return the market player status creating one if necessary
def getChatRoomPlayerStatus( dbPlayer ):
        playerSatus = ChatRoomPlayerUpToDateStatus.objects.filter( player = dbPlayer )
        if len( playerSatus )!= 0:
                return playerSatus[0]
        ps = ChatRoomPlayerUpToDateStatus( player = dbPlayer )
        ps.save()
        return ps

 

